home *** CD-ROM | disk | FTP | other *** search
/ Champak 141 / (Vol 141) Oct 17 2011.iso / Games / Clueless.swf / scripts / Common / ParticleSystem / Particle.as < prev   
Encoding:
Text File  |  2011-10-17  |  3.5 KB  |  165 lines

  1. package Common.ParticleSystem
  2. {
  3.    import Common.FastMath;
  4.    import flash.display.MovieClip;
  5.    import flash.geom.Point;
  6.    
  7.    public class Particle extends MovieClip
  8.    {
  9.        
  10.       
  11.       private var age:uint;
  12.       
  13.       private var active:Boolean;
  14.       
  15.       private var life:uint;
  16.       
  17.       private var scale:Point;
  18.       
  19.       public var weight:Number;
  20.       
  21.       private var rotateAuto:Boolean;
  22.       
  23.       private var rotationRate:Number;
  24.       
  25.       public var index:uint;
  26.       
  27.       private var velocity:Point;
  28.       
  29.       public function Particle()
  30.       {
  31.          velocity = new Point();
  32.          scale = new Point();
  33.          super();
  34.          reset();
  35.       }
  36.       
  37.       public function grow(param1:Number) : void
  38.       {
  39.          scaleX = scaleY = FastMath.lerp(ScaleBirth,ScaleDeath,param1);
  40.       }
  41.       
  42.       public function get Life() : uint
  43.       {
  44.          return life;
  45.       }
  46.       
  47.       public function get Active() : Boolean
  48.       {
  49.          return active;
  50.       }
  51.       
  52.       public function set Weight(param1:Number) : *
  53.       {
  54.          this.weight = param1;
  55.       }
  56.       
  57.       public function set Life(param1:uint) : *
  58.       {
  59.          this.life = param1;
  60.       }
  61.       
  62.       public function set RotationRate(param1:Number) : *
  63.       {
  64.          this.rotationRate = param1;
  65.       }
  66.       
  67.       public function set Active(param1:Boolean) : *
  68.       {
  69.          this.active = param1;
  70.          visible = param1;
  71.       }
  72.       
  73.       public function set ScaleBirth(param1:Number) : *
  74.       {
  75.          scale.x = param1;
  76.       }
  77.       
  78.       public function set Index(param1:uint) : *
  79.       {
  80.          this.index = param1;
  81.       }
  82.       
  83.       public function revive(param1:Number, param2:Number) : void
  84.       {
  85.          life = FastMath.variance(param1,param2);
  86.          age = life;
  87.       }
  88.       
  89.       public function get ScaleDeath() : Number
  90.       {
  91.          return scale.y;
  92.       }
  93.       
  94.       public function reset() : *
  95.       {
  96.          life = 30;
  97.          age = life;
  98.          rotationRate = 0;
  99.          rotateAuto = false;
  100.          weight = 1;
  101.          visible = true;
  102.          velocity.x = 0;
  103.          velocity.y = 0;
  104.          mouseEnabled = false;
  105.       }
  106.       
  107.       public function get Weight() : Number
  108.       {
  109.          return weight;
  110.       }
  111.       
  112.       public function rotate() : void
  113.       {
  114.          if(rotateAuto)
  115.          {
  116.             this.rotation = Math.atan2(velocity.y,velocity.x) * FastMath.PIOVER180 - 90;
  117.          }
  118.          else
  119.          {
  120.             this.rotation += rotationRate;
  121.          }
  122.       }
  123.       
  124.       public function set RotateAuto(param1:Boolean) : *
  125.       {
  126.          this.rotateAuto = param1;
  127.       }
  128.       
  129.       public function get ScaleBirth() : Number
  130.       {
  131.          return scale.x;
  132.       }
  133.       
  134.       public function get Index() : uint
  135.       {
  136.          return index;
  137.       }
  138.       
  139.       public function setVelocityDir(param1:Number, param2:int) : void
  140.       {
  141.          velocity = FastMath.magDir(param1,param2);
  142.       }
  143.       
  144.       public function set Age(param1:uint) : *
  145.       {
  146.          this.age = param1;
  147.       }
  148.       
  149.       public function set ScaleDeath(param1:Number) : *
  150.       {
  151.          scale.y = param1;
  152.       }
  153.       
  154.       public function get Age() : uint
  155.       {
  156.          return age;
  157.       }
  158.       
  159.       public function get Velocity() : Point
  160.       {
  161.          return velocity;
  162.       }
  163.    }
  164. }
  165.